/**
 * Class: PlayScales
 *
 * Purpose: 
 *
 * Created: Jan 29, 2010 @ 11:43:23 PM
 * @author Ken Scott
 */
package org.openfantasia.musica.test;

import org.openfantasia.musica.Musica;
import org.openfantasia.musica.events.EventList;
import org.openfantasia.musica.events.Note;
import org.openfantasia.musica.instruments.Sample;

import java.io.File;

public class PlayScales {

	public static void main(String[] args) {
		Musica mc = new Musica();
		mc.setBPM(120);

		EventList list = createPlaylist(mc);
		list.play();
	}


	public static EventList createPlaylist(Musica mc) {
		EventList result = new EventList(mc);

		File f = new File("Y:/samples/techno/TNRG_Trance_Synth_051.wav");
		Sample sample = new Sample(mc, f.getAbsolutePath(), "A4");
		Note n = new Note(mc, sample, "A4", .5, (int) sample.getDuration());
		result.addAfter(n);
		n = new Note(mc, sample, "Cs4", .5, (int) sample.getDuration());
		result.addAfter(n);
		n = new Note(mc, sample, "B4", .5, (int) sample.getDuration());
		result.addAfter(n);
		n = new Note(mc, sample, "Fs3", .5, (int) sample.getDuration());
		result.addAfter(n);

//		File[] files = new File("Y:\\samples\\techno").listFiles();
//		for (File file : files) {
//			Sample sample = new Sample(file.getAbsolutePath(), "A4");
//			Note n = new Note(sample, "A4", .5, (int) sample.getDuration());
//			result.addAfter(n);
//
//			Log l = new Log(sample.getName());
//			result.addOver(l);
//		}

//		Instrument sine = new Sine();
//		Instrument saw = new Saw();
//		Instrument square = new Square();
//		Instrument sample = new Sample("Y:\\samples\\keyboard\\Arp 01 funky.wav");
//
//		int tones = 14;
//		double volume = 0.5f / (double) tones;
//
//		Note n1 = new Note(square, "D3", .5, Musica.NOTE_16);
//		Note n2 = new Note(square, "D3", .5, Musica.NOTE_8);
//		Note n3 = new Note(sample, "D3", .5, Musica.NOTE_2);
//		Chord c4 = new Chord(new Scale("A3", Musica.MAJOR, tones), sine, volume, Musica.NOTE_4);
//		Chord c8 = new Chord(new Scale("A3", Musica.MAJOR, tones), sine, volume, Musica.NOTE_8);
//
//		Note nA = n1;
//		Note nB = n2;
//		for(int i = 0; i < 128; i++) {
////			int amount = PMath.randomSign() * PMath.random(0, 2);
////			nA = (Note) nA.transpose(amount);
////			result.addAfter(nA);
////			nB = (Note) nB.transpose(-amount);
////			result.addOver(nB);
//			result.addAfter(n3.transpose(1));
//		}

//		result.add(new Chord(new Scale("A4", Musica.MAJOR, tones), sine, volume, Musica.NOTE_4));
//		result.add(new Chord(new Scale("Ab4", Musica.MAJOR, tones), sine, volume, Musica.NOTE_4));
//		result.add(new Chord(new Scale("B4", Musica.MAJOR, tones), sine, volume, Musica.NOTE_4));
//		result.add(new Chord(new Scale("C4", Musica.MAJOR, tones), sine, volume, Musica.NOTE_4));
//		result.add(new Chord(new Scale("Cb4", Musica.MAJOR, tones), sine, volume, Musica.NOTE_4));
//		result.add(new Chord(new Scale("D4", Musica.MAJOR, tones), sine, volume, Musica.NOTE_4));
//		result.add(new Chord(new Scale("Db4", Musica.MAJOR, tones), sine, volume, Musica.NOTE_4));
//		result.add(new Chord(new Scale("E4", Musica.MAJOR, tones), sine, volume, Musica.NOTE_4));
//		result.add(new Chord(new Scale("F4", Musica.MAJOR, tones), sine, volume, Musica.NOTE_4));
//		result.add(new Chord(new Scale("Fb4", Musica.MAJOR, tones), sine, volume, Musica.NOTE_4));
//		result.add(new Chord(new Scale("G4", Musica.MAJOR, tones), sine, volume, Musica.NOTE_4));
//		result.add(new Chord(new Scale("Gb4", Musica.MAJOR, tones), sine, volume, Musica.NOTE_4));

		return result;
	}
}
